<!DOCTYPE html>
<html>
<head>
    <title>生产设备清单</title>
    #parse("sys/header.html")
    <style>
        .sugon_upload_btn {
            display: -webkit-inline-box;
            display: inline-block;
        }

        .leftHeight {
            height: 85vh;
            overflow: auto;
        }

        ::-webkit-scrollbar {
            width: 10px;
            height: 10px;
        }

        ::-webkit-scrollbar-thumb {
            border-radius: 10px;
            -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
            background: #a8a5a5;
        }

        .workShop {
            position: absolute;
            top: 0;
            width: 100%;
            height: 25px;
            background-color: white;
        }
    </style>
</head>
<body>
<div id="rrapp" v-cloak>
    <div id="reviewLayer" style="display: none;">
        <form class="form-horizontal" style="width: 350px;">
            <div class="form-group">
                <div class="form-group">
                    <div class="col-sm-2 control-label">已闲置列表</div>
                    <div class v-for="device in deviceList">{device.devName}</div>
                </div>
            </div>
        </form>
    </div>
    <div id="changeLayer" style="display: none;padding:10px;">
        <i-form ref="formValidate" :model="devChangeRecord" :label-width="80">
            <Row>
                <i-col span="11">
                    <Form-item label="设备编码" prop="partId">
                        <i-input v-model="devChangeRecord.devCode" placeholder="设备编码" disabled></i-input>
                    </Form-item>
                </i-col>
                <i-col span="11">
                    <Form-item label="设备名称" prop="devName">
                        <i-input v-model="devChangeRecord.devName" placeholder="设备名称" disabled></i-input>
                    </Form-item>
                </i-col>
            </Row>
            <Row>
                <i-col span="11">
                    <Form-item label="生产线名称" prop="devName">
                        <i-input v-model="devChangeRecord.devName" placeholder="生产线名称" disabled></i-input>
                    </Form-item>
                </i-col>
                <i-col span="11">
                    <Form-item label="设备状态" prop="devStatus">
                        <i-select v-model="devChangeRecord.devStatus" placeholder="设备状态">
                            <i-option v-for="devStatus in devStatusList2" :value="devStatus.value"
                                      :key="devStatus.value">{{devStatus.name}}
                            </i-option>
                        </i-select>
                    </Form-item>
                </i-col>
            </Row>
            <Row>
                <i-col span="11">
                    <Form-item label="工序名称" prop="devProceName">
                        <i-input v-model="devChangeRecord.devProceName" placeholder="工序名称" disabled></i-input>
                    </Form-item>
                </i-col>
                <i-col span="11">
                    <Form-item label="工序号" prop="devProceNo">
                        <i-input v-model="devChangeRecord.devProceNo" placeholder="工序号" disabled></i-input>
                    </Form-item>
                </i-col>
            </Row>
            <Row>
                <i-col span="11">
                    <Form-item label="自编号" prop="autoNo">
                        <i-input v-model="devChangeRecord.autoNo" placeholder="自编号" disabled></i-input>
                    </Form-item>

                </i-col>
                <i-col span="11">
                    <Form-item label="使用单位" prop="useDept">
                        <i-input v-model="devChangeRecord.useDept" placeholder="使用单位" disabled></i-input>
                    </Form-item>
                </i-col>
            </Row>
            <Row>
                <i-col span="11">
                    <Form-item label="验收日期" prop="checkDate">
                        <Date-picker type="date" format="yyyy-MM-dd" v-model="devChangeRecord.checkDate"
                                     placeholder="验收日期" disabled></Date-picker>
                    </Form-item>

                </i-col>
                <i-col span="11">
                    <Form-item label="特种设备" prop="isSpec">
                        <i-select v-model="devChangeRecord.isSpec" disabled>
                            <i-option value="1">普通设备</i-option>
                            <i-option value="2">特种设备</i-option>
                        </i-select>
                    </Form-item>
                </i-col>
            </Row>
            <Row>
                <i-col span="11">
                    <Form-item label="规格型号" prop="reserve1">
                        <i-input v-model="devChangeRecord.reserve1" placeholder="规格型号" disabled></i-input>
                    </Form-item>
                </i-col>
                <i-col span="11">
                    <Form-item label="出厂编号" prop="checkReason">
                        <i-input v-model="devChangeRecord.checkReason" placeholder="出厂编号" disabled></i-input>
                    </Form-item>
                </i-col>
            </Row>
            <Row>
                <i-col span="11">
                    <Form-item label="原值" prop="origVal">
                        <i-input v-model="devChangeRecord.origVal" placeholder="原值" disabled></i-input>
                    </Form-item>
                </i-col>
                <i-col span="11">
                    <Form-item label="净值" prop="netVal">
                        <i-input v-model="devChangeRecord.netVal" placeholder="净值" disabled></i-input>
                    </Form-item>
                </i-col>
            </Row>
        </i-form>
    </div>
    <div v-show="showList">
        <Row :gutter="16" style="margin: 8px 0px 0px 1px">
            <div class="search-group">
                <i-col span="2">
                    <i-input v-model="q.devCode" @on-enter="query" placeholder="设备编码"></i-input>
                </i-col>
                <i-col span="2">
                    <i-input v-model="q.devName" @on-enter="query" placeholder="设备名称"></i-input>
                </i-col>
                <i-col span="2">
                    <i-input v-model="q.faCode" @on-enter="query" placeholder="供应厂家编码"></i-input>
                </i-col>
                <i-col span="2">
                    <i-input v-model="q.faName" @on-enter="query" placeholder="供应厂家名称"></i-input>
                </i-col>
                <i-col span="3">
                    <i-select placeholder="设备大类" v-model="q.devTypeB" @on-change="getDevTypeM">
                        <i-option v-for="typeB in devTypeBList" :value="typeB.typeCode" :key="typeB.typeCode">
                            {{typeB.typeCode}} {{typeB.typeName}}
                        </i-option>
                    </i-select>
                </i-col>
                <i-col span="3">
                    <i-select placeholder="设备中类" v-model="q.devTypeM" @on-change="getDevTypeS">
                        <i-option v-for="typeM in devTypeMList" :value="typeM.typeCode" :key="typeM.typeCode">
                            {{typeM.typeCode}} {{typeM.typeName}}
                        </i-option>
                    </i-select>
                </i-col>
                <i-col span="3">
                    <i-select placeholder="设备小类" v-model="q.devTypeS">
                        <i-option v-for="typeS in devTypeSList" :value="typeS.typeCode" :key="typeS.typeCode">
                            {{typeS.typeCode}} {{typeS.typeName}}
                        </i-option>
                    </i-select>
                </i-col>
                <i-col span="3">
                    <i-select v-model="q.reserve4" placeholder="审核状态">
                        <i-option v-for="status in statusList" :value="status.value" :key="status.value">
                            {{status.name}}
                        </i-option>
                    </i-select>
                </i-col>
                <i-col span="1">
                    <i-button @click="query">查询</i-button>
                </i-col>
                <i-col span="1">
                    <i-button @click="reloadSearch">重置</i-button>
                </i-col>
            </div>
        </Row>
        <Row :gutter="16" style="margin: 3px 0px 0px 0px;">
            <div class="buttons-group">
                #if($shiro.hasPermission("devfile:imports"))
                <i-button type="primary" @click="exportData"><i class="fa fa-hand-o-up"></i>&nbsp;导出设备信息</i-button>
                #end
                #if($shiro.hasPermission("devfile:imports"))
                <Upload ref="uploadFile"
                        action="../deviceinfo/imports"
                        :format="['xlsx','xls']"
                        :before-upload="handleBeforeUpload"
                        :show-upload-list="false"
                        :on-success="handleSuccess2" :on-error="handleError2"
                        :on-format-error="handleFormatError" class="sugon_upload_btn">
                    <i-button type="primary"><i class="fa fa-hand-o-down"></i>&nbsp;导入</i-button>
                </Upload>
                #end
                #if($shiro.hasPermission("devfile:exportWord"))
                <i-button type="primary" @click="exportWord"><i class="fa fa-hand-o-up"></i>&nbsp;二维码导出</i-button>
                <i-button type="primary" @click="generateQrCode"><i class="fa fa-hand-o-up"></i>&nbsp;二维码生成</i-button>
                #end
                #if($shiro.hasPermission("devfile:devfile"))
                <i-button type="info" @click="devfile"><i class="fa fa-database"></i>&nbsp;设备图片维护</i-button>
                #end
                #if($shiro.hasPermission("deviceinfo:devcodeicc"))
                <i-button type="error" @click="devCodeIcc"><i class="fa fa-list-ol"></i>&nbsp;ICC代码维护</i-button>
                #end
                #if($shiro.hasPermission("deviceinfo:devLive"))
                <i-button type="warning" @click="addDevLeaveApply"><i class="fa fa-pencil-square-o"></i>&nbsp;设备闲置
                </i-button>
                #end
                #if($shiro.hasPermission("deviceinfo:addChange"))
                <i-button type="primary" @click="addChange"><i class="fa fa-anchor"></i>&nbsp;生产设备台账</i-button>
                #end
                #if($shiro.hasPermission("deviceinfo:addEqu"))
                <i-button type="info" @click="addEqu"><i class="fa fa-bars"></i>&nbsp;设备档案</i-button>
                #end
                #if($shiro.hasPermission("deviceinfo:changeStatus"))
                <i-button type="success" @click="changeStatus"><i class="fa fa-database"></i>&nbsp;设备变更</i-button>
                #end
                #if($shiro.hasPermission("deviceinfo:save"))
                <i-button type="info" @click="add"><i class="fa fa-plus"></i>&nbsp;新增</i-button>
                #end
                #if($shiro.hasPermission("deviceinfo:update"))
                <i-button type="warning" @click="update"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</i-button>
                #end
                #if($shiro.hasPermission("deviceinfo:check"))
                <i-button type="primary" @click="check"><i class="fa fa-gavel"></i>&nbsp;审核</i-button>
                #end
                #if($shiro.hasPermission("deviceinfo:delete"))
                <i-button type="error" @click="del"><i class="fa fa-trash-o"></i>&nbsp;删除</i-button>
                #end
            </div>
        </Row>
        <Row :gutter="16" style="margin: 8px 0px 0px 1px;">
            <i-col :xs="3" :sm="3" :md="3" :lg="3">
                <div class="leftHeight">
                    <div class="workShop">
                        <p class="text-center" style="font-size: 15px;">工厂/基地</p>
                    </div>
                    <div id="storeLayer" style="margin-top: 25px">
                        <ul id="storeTree" class="ztree"></ul>
                    </div>
                </div>
            </i-col>
            <i-col :xs="21" :sm="21" :md="21" :lg="21">
                <table id="jqGrid"></table>
            </i-col>
        </Row>
        <!--二维码展示-->
        <div id="qrcode" style="display: none"></div>
    </div>
    <!-- 备件审核弹窗 -->
    <div id="apply" style="display: none;">
        <i-form :label-width="80">
            <!--        <form class="form-horizontal" style="width: 350px;">-->
            <div class="form-group">
                <div class="form-group">
                    <Row>
                        <i-col span="22">
                            <Form-item label="审核列表">
                                {{approveDeviceList.join('、')}}
                            </Form-item>
                        </i-col>
                    </Row>
                    <Row>
                        <i-col span="22">
                            <Form-item label="审核状态">
                                <i-select v-model="approveParam.status" placeholder="审核状态">
                                    <i-option value="1">通过</i-option>
                                    <i-option value="2">未通过</i-option>
                                </i-select>
                            </Form-item>
                        </i-col>
                    </Row>
                    <Row>
                        <i-col span="22">
                            <Form-item label="备注信息">
                                <i-input type="textarea" v-model="approveParam.remark" rows="3"
                                         placeholder="备注信息"></i-input>
                            </Form-item>
                        </i-col>
                    </Row>
                </div>
            </div>
            <!--        </form>-->
        </i-form>
    </div>
    <Card v-show="!showList">
        <p slot="title">{{title}}</p>
        <i-form ref="formValidate" :model="deviceInfo" :rules="ruleValidate" label-position="right" :label-width="100">
            <Row>
                <i-col span="8">
                    <Form-item label="设备编码" prop="devCode" v-if="deviceInfo.id">
                        <i-input v-model="deviceInfo.devCode" placeholder="设备编码" disabled></i-input>
                    </Form-item>
                </i-col>
                <i-col span="8">
                    <Form-item label="底层设备码" prop="devLastCode">
                        <i-input v-model="deviceInfo.devLastCode" placeholder="底层设备码"></i-input>
                    </Form-item>
                </i-col>
                <i-col span="8">
                    <Form-item label="设备名称" prop="devName">
                        <i-input v-model="deviceInfo.devName" placeholder="设备名称"></i-input>
                    </Form-item>
                </i-col>
            </Row>
            <Row>
                <i-col span="8">
                    <Form-item label="大类" prop="devTypeB">
                        <i-select v-model="deviceInfo.devTypeB" @on-change="getDevTypeM">
                            <i-option v-for="typeB in devTypeBList" :value="typeB.typeCode" :key="typeB.typeCode"
                                      icon="md-arrow-dropdown-circle" @on-click="choose(typeB)">
                                {{typeB.typeCode}} {{typeB.typeName}}
                            </i-option>
                        </i-select>
                    </Form-item>
                </i-col>

                <i-col span="8">
                    <Form-item label="中类" prop="devTypeM">
                        <i-select v-model="deviceInfo.devTypeM" @on-change="getDevTypeS">
                            <i-option v-for="typeM in devTypeMList" :value="typeM.typeCode" :key="typeM.typeCode">
                                {{typeM.typeCode}} {{typeM.typeName}}
                            </i-option>
                        </i-select>
                    </Form-item>
                </i-col>
                <i-col span="8">
                    <Form-item label="小类" prop="devTypeS">
                        <i-select v-model="deviceInfo.devTypeS">
                            <i-option v-for="typeS in devTypeSList" :value="typeS.typeCode" :key="typeS.typeCode">
                                {{typeS.typeCode}} {{typeS.typeName}}
                            </i-option>
                        </i-select>
                    </Form-item>
                </i-col>
            </Row>
            <Row>
                <i-col span="8">
                    <Form-item label="生产线" prop="devProductName">
                        <i-input type="text" v-model="deviceInfo.devProductName" readonly="readonly"
                                 placeholder="生产线"></i-input>
                        <i-input v-model="deviceInfo.devFarm" v-show="false"></i-input>
                        <i-input v-model="deviceInfo.devProductCode" placeholder="生产线代码" v-show="false"></i-input>
                    </Form-item>
                </i-col>
                <i-col span="8">
                    <Form-item label="工序名称" prop="devProceName">
                        <i-input type="text" v-model="deviceInfo.devProceName" icon="md-arrow-dropdown-circle"
                                 readonly="readonly"
                                 @on-click="deptTree" placeholder="工序名称"></i-input>
                    </Form-item>
                </i-col>
                <i-col span="8">
                    <Form-item label="工序号" prop="devProceNo">
                        <i-input v-model="deviceInfo.devProceNo" placeholder="工序号" readonly="readonly"></i-input>
                    </Form-item>
                </i-col>
            </Row>
            <Row>
                <i-col span="8">
                    <Form-item label="设备型号" prop="reserve1">
                        <i-input v-model="deviceInfo.reserve1" placeholder="设备型号"></i-input>
                    </Form-item>
                </i-col>
                <i-col span="8">
                    <Form-item label="设备容量" prop="reserve2">
                        <i-input v-model="deviceInfo.reserve2" placeholder="设备容量(功率)"></i-input>
                    </Form-item>
                </i-col>
                <i-col span="8">
                    <Form-item label="所属项目" prop="devProject">
                        <i-input v-model="deviceInfo.devProject" placeholder="所属项目"></i-input>
                    </Form-item>
                </i-col>
            </Row>
            <Row>
                <i-col span="8">
                    <Form-item label="固资编号" prop="regNo">
                        <i-input v-model="deviceInfo.firmNo" placeholder="固资编号"></i-input>
                    </Form-item>
                </i-col>
                <i-col span="8">
                    <Form-item label="供应厂家" prop="devSupply">
                        <i-input v-model="deviceInfo.devSupplyName" placeholder="供应厂家" @on-click="loadFacType" readonly
                                 icon="md-arrow-dropdown-circle"></i-input>
                    </Form-item>
                </i-col>
                <i-col span="8">
                    <Form-item label="原值" prop="origVal">
                        <i-input v-model="deviceInfo.origVal" placeholder="原值"></i-input>
                    </Form-item>
                </i-col>
            </Row>
            <Row v-if="showCheck">
                <i-col span="8">
                    <Form-item label="出厂编号" prop="initCode">
                        <i-input v-model="deviceInfo.initCode" placeholder="设备出厂编号"></i-input>
                    </Form-item>
                </i-col>
                <i-col span="8">
                    <Form-item label="注册编号" prop="regNo">
                        <i-input v-model="deviceInfo.regNo" placeholder="注册编号"></i-input>
                    </Form-item>
                </i-col>
                <i-col span="8">
                    <Form-item label="合同编码" prop="devContractCode">
                        <i-input v-model="deviceInfo.devContractCode" placeholder="合同编码"></i-input>
                    </Form-item>
                </i-col>
            </Row>
            <Row>
                <i-col span="8">
                    <Form-item label="安装日期" prop="installDate">
                        <Date-picker v-model="deviceInfo.installDate" placeholder="安装日期"></Date-picker>
                    </Form-item>
                </i-col>
                <i-col span="8">
                    <Form-item label="验收日期" prop="checkDate">
                        <Date-picker v-model="deviceInfo.checkDate" placeholder="验收日期"></Date-picker>
                    </Form-item>
                </i-col>
                <i-col span="8">
                    <Form-item label="是否关联模具" prop="isModuleRelated">
                        <i-select placeholder="请选择是否关联模具" v-model="deviceInfo.isModuleRelated">
                            <i-option value="0">否</i-option>
                            <i-option value="1">是</i-option>
                        </i-select>
                    </Form-item>
                </i-col>
            </Row>
            <Row>
                <i-col span="8">
                    <Form-item label="设备种类" prop="devKind">
                        <i-select placeholder="请选择设备种类" v-model="deviceInfo.devKind">
                            <i-option value="1">生产设备</i-option>
                            <i-option value="7">能源设备</i-option>
                        </i-select>
                    </Form-item>
                </i-col>
                <i-col span="8" v-show="deviceInfo.devKind == '7'">
                    <Form-item label="当前运行时长" prop="currentLifeSpan">
                        <i-input v-model="deviceInfo.currentLifeSpan" type="number" placeholder="请输入当前运行时长"></i-input>
                    </Form-item>
                </i-col>
                <i-col span="8" v-show="deviceInfo.devKind == '7'">
                    <Form-item label="下次保养寿命" prop="maintenanceLifeSpan">
                        <i-input v-model="deviceInfo.maintenanceLifeSpan" type="number"
                                 placeholder="请输入下次保养寿命"></i-input>
                    </Form-item>
                </i-col>
            </Row>
            <Row>
                <i-col span="5">
                    <Form-item label="设备图片" prop="url">
                        <i-hidden v-model="deviceInfo.url" placeholder="请上传" readonly/>
                        <i-input v-model="picUrl" placeholder="请上传(默认主位图片)" readonly/>
                    </Form-item>
                </i-col>
                <i-col span="2">
                    <Form-item :label-width="1">
                        <Upload ref="uploadFile" multiple style="width: 300px;" action="../sys/oss/device/file"
                                :on-success="handleSuccess"
                                :on-format-error="handleError"
                                :show-upload-list="false"
                                :on-exceeded-size="handleMaxSize">
                            <i-button icon="ios-cloud-upload-outline">上传</i-button>
                        </Upload>
                    </Form-item>
                </i-col>
                <i-col span="8" offset="1">
                    <Form-item label="ERP编码"  >
                        <i-input v-model="deviceInfo.erpCode" placeholder="暂无ERP编码" />
                    </Form-item>
                </i-col>
            </Row>
            <Row>
                <i-col span="16">
                    <Form-item label="设备描述" prop="devDescr">
                        <i-input type="textarea" v-model="deviceInfo.devDescr" placeholder="设备描述"></i-input>
                    </Form-item>
                </i-col>
            </Row>
            <Form-item>
                <i-button type="primary" @click="handleSubmit('formValidate')">提交</i-button>
                <i-button type="warning" @click="reload" style="margin-left: 8px">
                    返回
                </i-button>
                <i-button type="info" @click="handleReset('formValidate')" style="margin-left: 8px">重置</i-button>
            </Form-item>
        </i-form>
    </Card>
</div>
<div id="categoryLayer" style="display: none;padding:10px;">
    <ul id="categoryTree" class="ztree"></ul>
</div>
<script src="${rc.contextPath}/js/sys/deviceinfo.js?_${date.systemTime}"></script>
</body>
</html>
